import wRequest from "../index";
import { IAccount, ILoginData } from "./type";
import { IDataType } from "../types";

enum LoginAPI {
  AccountLogin = "/login",
  LoginUserInfo = "/users/",
  UserMenus = "/role/",
}

// 请求用户登录前后相关数据
export function accountLoginRequest(account: IAccount) {
  return wRequest.post<IDataType<ILoginData>>({
    url: LoginAPI.AccountLogin,
    data: account,
  });
}

export function requestUserInfoById(id: number) {
  return wRequest.get<IDataType>({
    url: LoginAPI.LoginUserInfo + id,
  });
}

export function requestUserMenusByRoleId(id: number) {
  return wRequest.get<IDataType>({
    url: LoginAPI.UserMenus + id + "/menu",
  });
}
